package com.ruoyi.stuclient.controller;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.context.ThirdSessionHolder;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.stuclient.domain.vo.TodayCourseChapterVo;
import com.ruoyi.stuclient.service.IEwcChapterService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 章节信息Controller
 * 
 * @author zsp
 * @date 2025-05-04
 */
@RestController
@RequestMapping("/api/studentClient")
public class EwcChapterController extends BaseController
{
    @Autowired
    private IEwcChapterService ewcChapterService;

    /**
     * 学生端首页查询正在进行中的课程
     * @return AjaxResult
     */
    @Operation(summary = "学生端首页查询正在进行中的课程")
    @GetMapping("/getCourseInProgress")
    public AjaxResult getCourseInProgress() {
        List<TodayCourseChapterVo>  listCourse = ewcChapterService.getCourseInProgress(ThirdSessionHolder.getThirdSession().getId(), DateUtil.format(DateUtil.date(),"yyyy-MM-dd"));
        JSONObject resultJson = new JSONObject();
        resultJson.put("listCourse", listCourse);
        return AjaxResult.success("查询成功", resultJson);
    }

}
